package com.bobo.utis;

import com.zhenzi.sms.ZhenziSmsClient;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName:
 * @Description:
 * @Author:bobo
 * @Date:2021/12/24 9:56
 */
public class SendMsgUtil {

    /**
     *
     * @param phoneNum 发送的手机号
     * @param code 验证码
     * @param vsecond 验证过期秒数
     * @return
     */
    public static  String send(String phoneNum,String code,Integer vsecond){
        //调用榛子接口
        ZhenziSmsClient client = new ZhenziSmsClient("http://sms_developer.zhenzikj.com", "110630", "b4e3f9f0-64bd-4a5b-b49a-765d5fff470c");//https://sms_developer.zhenzikj.com
        Map<String, Object> params = new HashMap<String, Object>();
        //封装手机号
        params.put("number", phoneNum);
        //封装调用短信模板
        params.put("templateId", "7739");

        String[] templateParams = new String[2];
        //验证码
        templateParams[0] = code;
        templateParams[1] = vsecond+"秒";
        params.put("templateParams", templateParams);
        String result = null;
        try {
            result = client.send(params);//发手机短信
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
